package edu.aysf.service.impl;

import edu.aysf.dao.UserDao;
import edu.aysf.entity.UserEntity;
import edu.aysf.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public List<UserEntity> selectUserById(int id) {
        return userDao.selectUserById(id);
    }

    @Override
    public List<UserEntity> selectUserName(String name) {
        return userDao.selectUserName(name);
    }

    @Override
    public List<UserEntity> selectUser() {
        return userDao.selectUser();
    }

    @Override
    public int createUser(String name,String password, int age, String sex, String identity, String isadmin, String isdelete) {
        return userDao.createUser(name,password,age,sex,identity,isadmin,isdelete);
    }

    // 更新用户
    @Override
    public int updateUser(int id, String name,String password, int age, String sex, String identity, String isadmin, String isdelete) {
        return userDao.updateUser(id,name,password,age,sex,identity,isadmin,isdelete);
    }

    // 逻辑删除用户，更新isdelete字段
    @Override
    public void deleteUser(int id) {
        userDao.deleteUser(id);
    }

    @Override
    public int selectUserByNamePwd(String name, String password) {
        return userDao.selectUserByNamePwd(name,password);
    }
}
